package com.hundsun.cprs.yyt.service.order.enums;

import java.util.HashMap;
import java.util.Map;

public enum EnumsOrderStatus {
    
    WAIT_PAY(0,"待支付","wait_pay"),
    PAID(1,"已支付","paid"),
    WAIT_DELIVERY(2,"待发货","wait_delivery"),
    DELIVERED(3,"待收货","delivered"),
    COMPELETED(4,"已完成","completed"),
    ENTRUST(5,"已委售","entrust"),
    RETURN(6,"已退货","return")
    ;
    
    private Integer status;
    private String desc;
    //page code
    private String code;
    private EnumsOrderStatus(Integer status,String desc,String code){
        this.status = status;
        this.desc = desc;
        this.code = code;
    }
    
    /**
     * 全局索引池
     */
    private static Map<Integer, EnumsOrderStatus> pool = new HashMap<Integer, EnumsOrderStatus>();
    static {
        for (EnumsOrderStatus et : EnumsOrderStatus.values()) {
            pool.put(et.getStatus(), et);
        }
    }
    /**
     * 根据内容索引
     *
     * @param code
     * @return
     */
    public static EnumsOrderStatus indexByValue(Integer status) {
        return pool.get(status);
    }
    
    public static EnumsOrderStatus indexByCode(String code){
        for (EnumsOrderStatus et : EnumsOrderStatus.values()) {
            if (et.getCode().equals(code)) {
                return et;
            }
        }
        return null;
    }

    public static Map<Integer, EnumsOrderStatus> toMap() {
        return pool;
    }
    
    public int getStatus() {
        return status;
    }
    public String getDesc() {
        return desc;
    }
    public String getCode() {
        return code;
    }

}
